import csv

from pyecharts import options as opts
from pyecharts.charts import Pie
from pyecharts.globals import ThemeType

str_name = '点'
with open('./file/time_latest.csv') as csv_file:
    reader = csv.reader(csv_file)
    x = [str(row[0] + str_name) for row in reader]
    print(x)
with open('./file/time_latest.csv') as csv_file:
    reader = csv.reader(csv_file)
    y = [int(row[1]) for row in reader]
    print(y)
num = y
lab = x
(Pie(init_opts=opts.InitOpts(width='1650px', height='500px', theme=ThemeType.LIGHT, )).set_global_opts(
    title_opts=opts.TitleOpts(title="雪中悍刀行每小时评论统计", title_textstyle_opts=opts.TextStyleOpts(font_size=27)),
    legend_opts=opts.LegendOpts(pos_top="8%", pos_left="4%"), )
 .add(series_name='', center=[250, 300], data_pair=[(j, i) for i, j in zip(num, lab)])
 .add(series_name='', center=[810, 300], data_pair=[(j, i) for i, j in zip(num, lab)], radius=['40%', '75%'])
 .add(series_name='', center=[1350, 300], data_pair=[(j, i) for i, j in zip(num, lab)], rosetype='radius')
 ).render('./Html/pie_pyecharts2.html')
